import { Public } from '@/decorators/visit.decorator';
import { Controller, Delete, Get, Query } from '@nestjs/common';
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
import { UserService } from './user.service';

@ApiTags('后台用户管理')
@Controller('admin/user')
export class UserController {
  constructor(private readonly userService: UserService) {}

  @Public()
  @ApiOperation({
    summary: '用户列表查询',
  })
  @ApiBearerAuth()
  @Get('/userListSelect')
  matchListSelect(
    @Query('id') id = 0,
    @Query('nickName') nickName = '',
    @Query('page') page = 1,
    @Query('size') size = 10,
  ) {
    return this.userService.userListSelect({
      page: Number(page),
      size: Number(size),
      id: Number(id),
      nickName,
    });
  }

  @Public()
  @ApiOperation({
    summary: '用户数据删除',
  })
  @ApiBearerAuth()
  @Delete('/deleteUser')
  deleteUser(@Query('id') id: number) {
    return this.userService.deleteUser(id);
  }
}
